from django.db import models
from django.contrib.auth import get_user_model

OAUSer = get_user_model()

class AbsentStatusChoices(models.IntegerChoices):
    # 已激活
    AUDITING = 1
    # 未激活
    PASS = 2
    # 已锁定
    REJECT = 3

class AbsentType(models.Model):
    name = models.CharField(max_length=100)
    create_time = models.DateTimeField(auto_now_add=True)

class Absent(models.Model):
    title = models.CharField(max_length=200)
    request_content = models.TextField()
    absent_type = models.ForeignKey(AbsentType, on_delete=models.CASCADE, related_name='absent', related_query_name='absent')
    requester = models.ForeignKey(OAUSer, on_delete=models.CASCADE, related_name='my_absents', related_query_name='my_absents')
    responder = models.ForeignKey(OAUSer, on_delete=models.CASCADE, related_name='sub_absent', related_query_name='sub_absent', null=True)
    status = models.IntegerField(choices=AbsentStatusChoices, default=AbsentStatusChoices.AUDITING)
    start_date =  models.DateField()
    end_date = models.DateField()
    create_time = models.DateTimeField(auto_now_add=True)
    response_content = models.TextField(blank=True)

    class Meta:
        ordering = ('-create_time',)